class Player(object):
    numbers = 0 # 类属性
    def __init__(self, name,age,city): #初始化函数
        self.name = name # 实例属性
        self.age = age
        self.city = city
        Player.numbers += 1
jj = Player("林俊杰",30,"新加坡")
print(Player.numbers)
print(jj.__dict__)
print(Player.numbers)


print("🍎" * 20)

class Weapon(object):
    numbers = 0 # 类属性
    max_damage = 10000 # 类属性
    level = ["钻石","星耀","王者","荣耀"] # 类属性
    def __init__(self,name,damage,level):
        self.name = name
        self.damage = damage
        self.level = level
        Weapon.numbers += 1
        if damage > Weapon.max_damage:
            raise Exception("最大的伤害值是10000，请重试")
        if level not in Weapon.level:
            raise Exception("段位设置错误")

try:
    gun = Weapon('magic',2000,"王者")
    print("欢迎荣耀王者的第%d个" % Weapon.numbers)
    arrow = Weapon('arrow', 1000, "荣耀")
    print("欢迎荣耀王者的第%d个" % Weapon.numbers)
except Exception as e:
    print(e)



